/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";

var $protobuf = require("protobufjs/minimal.js");

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.CMD = (function() {

    /**
     * Properties of a CMD.
     * @exports ICMD
     * @interface ICMD
     */

    /**
     * Constructs a new CMD.
     * @exports CMD
     * @classdesc Represents a CMD.
     * @implements ICMD
     * @constructor
     * @param {ICMD=} [properties] Properties to set
     */
    function CMD(properties) {
        if (properties)
            for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                if (properties[keys[i]] != null)
                    this[keys[i]] = properties[keys[i]];
    }

    /**
     * Creates a new CMD instance using the specified properties.
     * @function create
     * @memberof CMD
     * @static
     * @param {ICMD=} [properties] Properties to set
     * @returns {CMD} CMD instance
     */
    CMD.create = function create(properties) {
        return new CMD(properties);
    };

    /**
     * Encodes the specified CMD message. Does not implicitly {@link CMD.verify|verify} messages.
     * @function encode
     * @memberof CMD
     * @static
     * @param {ICMD} message CMD message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    CMD.encode = function encode(message, writer) {
        if (!writer)
            writer = $Writer.create();
        return writer;
    };

    /**
     * Encodes the specified CMD message, length delimited. Does not implicitly {@link CMD.verify|verify} messages.
     * @function encodeDelimited
     * @memberof CMD
     * @static
     * @param {ICMD} message CMD message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    CMD.encodeDelimited = function encodeDelimited(message, writer) {
        return this.encode(message, writer).ldelim();
    };

    /**
     * Decodes a CMD message from the specified reader or buffer.
     * @function decode
     * @memberof CMD
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @param {number} [length] Message length if known beforehand
     * @returns {CMD} CMD
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    CMD.decode = function decode(reader, length) {
        if (!(reader instanceof $Reader))
            reader = $Reader.create(reader);
        var end = length === undefined ? reader.len : reader.pos + length, message = new $root.CMD();
        while (reader.pos < end) {
            var tag = reader.uint32();
            switch (tag >>> 3) {
            default:
                reader.skipType(tag & 7);
                break;
            }
        }
        return message;
    };

    /**
     * Decodes a CMD message from the specified reader or buffer, length delimited.
     * @function decodeDelimited
     * @memberof CMD
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @returns {CMD} CMD
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    CMD.decodeDelimited = function decodeDelimited(reader) {
        if (!(reader instanceof $Reader))
            reader = new $Reader(reader);
        return this.decode(reader, reader.uint32());
    };

    /**
     * Verifies a CMD message.
     * @function verify
     * @memberof CMD
     * @static
     * @param {Object.<string,*>} message Plain object to verify
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
     */
    CMD.verify = function verify(message) {
        if (typeof message !== "object" || message === null)
            return "object expected";
        return null;
    };

    /**
     * Creates a CMD message from a plain object. Also converts values to their respective internal types.
     * @function fromObject
     * @memberof CMD
     * @static
     * @param {Object.<string,*>} object Plain object
     * @returns {CMD} CMD
     */
    CMD.fromObject = function fromObject(object) {
        if (object instanceof $root.CMD)
            return object;
        return new $root.CMD();
    };

    /**
     * Creates a plain object from a CMD message. Also converts values to other types if specified.
     * @function toObject
     * @memberof CMD
     * @static
     * @param {CMD} message CMD
     * @param {$protobuf.IConversionOptions} [options] Conversion options
     * @returns {Object.<string,*>} Plain object
     */
    CMD.toObject = function toObject() {
        return {};
    };

    /**
     * Converts this CMD to JSON.
     * @function toJSON
     * @memberof CMD
     * @instance
     * @returns {Object.<string,*>} JSON object
     */
    CMD.prototype.toJSON = function toJSON() {
        return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
    };

    /**
     * Gets the default type url for CMD
     * @function getTypeUrl
     * @memberof CMD
     * @static
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
     * @returns {string} The default type url
     */
    CMD.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
        if (typeUrlPrefix === undefined) {
            typeUrlPrefix = "type.googleapis.com";
        }
        return typeUrlPrefix + "/CMD";
    };

    /**
     * ID enum.
     * @name CMD.ID
     * @enum {number}
     * @property {number} DEFAULT=0 DEFAULT value
     * @property {number} GAME_SERVER_REGISTER=101 GAME_SERVER_REGISTER value
     * @property {number} CLIENT_PROTO_DISPATCH=102 CLIENT_PROTO_DISPATCH value
     * @property {number} NOTIFY_GAME_ROLE_LOGIN=103 NOTIFY_GAME_ROLE_LOGIN value
     * @property {number} PUSH_PROTO_TO_CLIENT=104 PUSH_PROTO_TO_CLIENT value
     * @property {number} ACCOUNT_REGISTER=10101 ACCOUNT_REGISTER value
     * @property {number} ACCOUNT_LOGIN=10102 ACCOUNT_LOGIN value
     * @property {number} ROLE_CREATE=10201 ROLE_CREATE value
     * @property {number} ROLE_LOGIN=10202 ROLE_LOGIN value
     */
    CMD.ID = (function() {
        var valuesById = {}, values = Object.create(valuesById);
        values[valuesById[0] = "DEFAULT"] = 0;
        values[valuesById[101] = "GAME_SERVER_REGISTER"] = 101;
        values[valuesById[102] = "CLIENT_PROTO_DISPATCH"] = 102;
        values[valuesById[103] = "NOTIFY_GAME_ROLE_LOGIN"] = 103;
        values[valuesById[104] = "PUSH_PROTO_TO_CLIENT"] = 104;
        values[valuesById[10101] = "ACCOUNT_REGISTER"] = 10101;
        values[valuesById[10102] = "ACCOUNT_LOGIN"] = 10102;
        values[valuesById[10201] = "ROLE_CREATE"] = 10201;
        values[valuesById[10202] = "ROLE_LOGIN"] = 10202;
        return values;
    })();

    return CMD;
})();

module.exports = $root;
